home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / sounddt41src / aiff.h next >
C/C++ Source or Header  |  1999-04-19  |  1KB  |  58 lines

  1.  
  2. /*
  3. **    aiff.h
  4. **    stolen from Olaf Barthels' aiff.dt
  5. */
  6.  
  7. #ifndef AIFF_H
  8. #define AIFF_H
  9.  
  10. #ifndef EXEC_TYPES_H
  11. #include <exec/types.h>
  12. #endif
  13.  
  14. typedef struct {
  15.     UWORD    exponent;            // Exponent, bit #15 is sign bit for mantissa
  16.     ULONG    mantissa[2];            // 64 bit mantissa
  17. } extended;
  18.  
  19. // Audio Interchange Format chunk data
  20.  
  21. #define ID_AIFF    MAKE_ID('A', 'I', 'F', 'F')
  22.  
  23. #define ID_COMM     MAKE_ID('C', 'O', 'M', 'M')
  24. #define ID_SSND     MAKE_ID('S', 'S', 'N', 'D')
  25.  
  26. // "COMM" chunk header
  27.  
  28. typedef struct {
  29.     WORD        numChannels;        // Number of channels
  30.     ULONG        numSampleFrames;    // Number of sample frames
  31.     WORD        sampleSize;        // Number of bits per sample point
  32.     extended    sampleRate;        // Replay rate in samples per second
  33. } CommonChunk;
  34.  
  35. // "SSND" chunk header
  36.  
  37. typedef struct {
  38.     ULONG    offset,                // Offset to sound data, for block alignment
  39.             blockSize;            // Size of block data is aligned to
  40. } SampledSoundHeader;
  41.  
  42. static void ulong2extended( ULONG value, extended *ex )
  43. {
  44.     ex->exponent = 31 + 16383;
  45.  
  46.     while( ( value & 0x80000000 ) == 0 )
  47.     {
  48.         value <<= 1;
  49.  
  50.         ex->exponent--;
  51.     }
  52.  
  53.     ex->mantissa[0] = value;
  54.     ex->mantissa[1] = 0;
  55. }
  56.  
  57. #endif
  58.